<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\SoftDeletes;

/**
 * @property int $id 
 * @property int $user_id 
 * @property float $amount 
 * @property string $remark 
 * @property string $bank_name 
 * @property string $bank_account 
 * @property string $bank_realname 
 * @property string $bank_idcard 
 * @property string $bank_phone 
 * @property int $status 
 * @property string $refusal_reason
 * @property int $cash_status
 * @property int $admin_id 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $deleted_at 
 */
class UserCash extends Model
{
    use SoftDeletes;

    public $dateFormat = 'U';

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user_cash';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'user_id' => 'integer', 'amount' => 'float', 'status' => 'integer', 'admin_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'integer'];
    /**
     * 定义状态字段
     * @var array
     */
    protected $appends = ['status_text','cash_status_text'];

    /**
     * 处理状态
     * @return mixed
     */
    public function getStatusTextAttribute()
    {
        $status=[
            0=>'待处理',
            1=>'已处理',
            2=>'已拒绝'
        ];
        return $status[$this->status];
    }

    /**
     * 提现状态
     *
     * @return mixed
     */
    public function getCashStatusTextAttribute()
    {

        $cash_status=[
            1 =>'提现中',
            2 =>'已到账',
            3 =>'提现失败'
        ];
        return $cash_status[$this->cash_status];
    }

    /**
     * 提现时间获取器
     *
     * @param $value
     * @return int|string
     */
    public function getStartTimeAttribute($value)
    {
        return date('Y-m-d H:i:s', $value);
    }

    /**
     * 到账时间获取器
     *
     * @param $value
     * @return int|string
     */
    public function getArrivalTimeAttribute($value)
    {
        return date('Y-m-d H:i:s', $value);
    }
}